Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Issues with modbus interfacer and pymodbus #63

Closed
wants to merge 5 commits into from

Conversation

cjthuys
Copy link
Contributor

@cjthuys cjthuys commented May 15, 2018

Removed py-modbus check from emonhub.py and added to modbus interfacer
resolved issues with import of EmonModbusTcpInterfacer in EmonFroniusModbusTcpInterfacer
moved fronius and modbus interfacers out of tmp directory. enabled fronius and modbus interfacers in init.py script

Removed Pymodbus check. This has been moved to EmonModbusTcpInterfacer.
…nterfacers/EmonFroniusModbusTcpInterfacer.py
@alexandrecuer
Copy link
Contributor

Hello

have you tested this with a version of pymodbus > 1.4.0 ?

To make it to work properly, I had to change line 108 of EmonmodbusTcpInterfacer.py from
decoder = BinaryPayloadDecoder.fromRegisters(self.rVal.registers, endian=Endian.Big)
to
decoder = BinaryPayloadDecoder.fromRegisters(self.rVal.registers, byteorder=Endian.Big, wordorder=Endian.Big)

cf the pull request submitted some times ago...
https://github.com/openenergymonitor/emonhub/pull/52/files

Alex

@glynhudson
Copy link
Member

glynhudson commented Dec 7, 2018

Hi guys, very sorry for the very slow reply. I don't know how I missed this. I just got prompted to search for this by a forum member reporting a issue: https://community.openenergymonitor.org/t/monitor-fronius-primo-5/9437

I've just tested this PR and I get an error ImportError: No module named pymodbus.constants. I'm running standard emonSD-30Oct18. This does not have pymodbus install by default. I will add pymodbus to a future emonPi update. However, would it be possible to add a check to see if pymodbus is not installed since many users of emonhub will not be used modbus but still require emonhub to run. This error fully crashed emonhub.

Please include @alexandrecuer changes if required, I see the current version is pymodbus-2.1.0

Update:

It seems even after installing pymodbus (pip install pymodbus) I'm still getting this error and failing to start emonhub after apply this PR:

Dec 07 21:46:57 emonpi2 systemd[1]: Started LSB: Start/stop emonHub.
Dec 07 21:47:00 emonpi2 emonhub[24366]: Traceback (most recent call last):
Dec 07 21:47:00 emonpi2 emonhub[24366]:   File "/usr/share/emonhub/emonhub.py", line 24, in <module>
Dec 07 21:47:00 emonpi2 emonhub[24366]:     from interfacers import *
Dec 07 21:47:00 emonpi2 emonhub[24366]:   File "/home/pi/emonhub/src/interfacers/EmonModbusTcpInterfacer.py", line 16, in <module>
Dec 07 21:47:00 emonpi2 emonhub[24366]:     from pymodbus.constants import Endian
Dec 07 21:47:00 emonpi2 emonhub[24366]: ImportError: No module named pymodbus.constants

@alexandrecuer
Copy link
Contributor

@glynhudson : my PR should fix the problems encountered (ImportError, crash if pymodbus not installed, etc, etc)...

It has been tested on various modbus and mbus devices and it is working fine.....

Anyway, I don't have a fronius device so I cannot test the fronius part...anyway, the EmonModbusTcpInterfacer is enough to work with modbus devices...

I use to install pymodbus with git rather than using pip..Anyway, there should be no difference

Alex

@glynhudson
Copy link
Member

Thanks @alexandrecuer , I've tested and merged you PR.

I will close this PR since it's a duplicate of #52

@glynhudson glynhudson closed this Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants